#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 110;
const LL mod = 1e9 + 7;

LL n, i, j, x, y;
LL f[N][N];

/*
f[i][j]代表区间[i,j]在包含有n的情况下的双调排列的方案数

f[i - 1][j] += if(ok) f[i][j]
f[i][j + 1] += if(ok) f[i][j]
*/

bool check(int pos, int val){
    if(pos == i && val != x) return false;
    if(val == x && pos != i) return false;
    if(pos == j && val != y) return false;
    if(pos != j && val == y) return false;

    return true;
}

void solve(){
    cin >> n >> i >> j >> x >> y;

    for(int i = 0; i <= n; i ++){
        for(int j = 0; j <= n; j ++){
            f[i][j] = 0;
        }
    }

    for(int i = 2; i <= n - 1; i ++){
        if(check(i, n)) f[i][i] = 1;
    }

    for(int len = 1; len <= n - 1; len ++){
        for(int l = 1; l + len - 1 <= n; l ++){
            int r = l + len - 1;
            int num = n - len;
            if(check(l - 1, num)){
                f[l - 1][r] = (f[l - 1][r] + f[l][r]) % mod;
            }

            if(check(r + 1, num)){
                f[l][r + 1] = (f[l][r + 1] + f[l][r]) % mod;
            }
        }
    }

    cout << f[1][n] << '\n';

}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


    int T;
    cin >> T;
    while(T--){
        solve();
    }

    return 0;
}